home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / spiderweb / src / c / tangle.c < prev   
Encoding:
C/C++ Source or Header  |  1993-04-04  |  43.2 KB  |  2,215 lines

  1. /*1:*/
  2. #line 44 "tangle.web"
  3.  
  4. /*4:*/
  5. #line 15 "common.h"
  6.  
  7. #line 16 "common.h"
  8. #include<stdio.h>
  9.  
  10. /*:4*//*94:*/
  11. #line 1046 "tangle.web"
  12.  
  13. #line 1047 "tangle.web"
  14. #include"ctype.h"
  15.  
  16. /*:94*/
  17. #line 45 "tangle.web"
  18.  
  19. /*3:*/
  20. #line 9 "common.h"
  21.  
  22. typedef short boolean;
  23. typedef char unsigned eight_bits;
  24. extern boolean program;
  25. extern int phase;
  26.  
  27. /*:3*//*5:*/
  28. #line 24 "common.h"
  29.  
  30. typedef char ASCII;
  31. typedef char outer_char;
  32. extern ASCII xord[];
  33. extern outer_char xchr[];
  34. ASCII mod_text[400+1];
  35. ASCII *mod_text_end= mod_text+400;
  36. ASCII *id_first;
  37. ASCII *id_loc;
  38.  
  39. /*:5*//*6:*/
  40. #line 37 "common.h"
  41.  
  42. #line 38 "common.h"
  43. extern ASCII buffer[];
  44. extern ASCII *buffer_end;
  45. extern ASCII *loc;
  46. extern ASCII *limit;
  47.  
  48. /*:6*//*7:*/
  49. #line 55 "common.h"
  50.  
  51. typedef struct name_info{
  52. ASCII *byte_start;
  53. struct name_info *link;
  54. union{
  55. struct name_info *Rlink;
  56.  
  57. eight_bits Ilk;
  58.  
  59. }dummy;
  60. ASCII *equiv_or_xref;
  61. }name_info;
  62. typedef name_info *name_pointer;
  63. typedef name_pointer *hash_pointer;
  64. extern ASCII byte_mem[];
  65. extern ASCII *byte_mem_end;
  66. extern name_info name_dir[];
  67. extern name_pointer name_dir_end;
  68. extern name_pointer name_ptr;
  69. extern ASCII *byte_ptr;
  70. extern name_pointer hash[];
  71. extern hash_pointer hash_end;
  72. extern hash_pointer h;
  73. extern name_pointer id_lookup();
  74. extern name_pointer mod_lookup();
  75. extern name_pointer prefix_lookup();
  76.  
  77. /*:7*//*8:*/
  78. #line 98 "common.h"
  79.  
  80. extern history;
  81.  
  82. /*:8*//*9:*/
  83. #line 109 "common.h"
  84.  
  85. extern include_depth;
  86. extern FILE *file[];
  87. extern FILE *change_file;
  88. extern char C_file_name[];
  89. extern char tex_file_name[];
  90. extern char file_name[][60];
  91.  
  92. extern char change_file_name[];
  93. extern line[];
  94. extern change_line;
  95. extern boolean input_has_ended;
  96. extern boolean changing;
  97.  
  98. /*:9*//*10:*/
  99. #line 124 "common.h"
  100.  
  101. #line 125 "common.h"
  102. typedef unsigned short sixteen_bits;
  103. extern sixteen_bits module_count;
  104. extern boolean changed_module[];
  105. extern boolean print_where;
  106.  
  107. /*:10*//*11:*/
  108. #line 131 "common.h"
  109.  
  110. #line 132 "common.h"
  111. extern int argc;
  112. extern char * *argv;
  113. extern no_xref;
  114.  
  115. /*:11*//*12:*/
  116. #line 144 "common.h"
  117.  
  118. FILE *C_file;
  119. FILE *tex_file;
  120. #line 81 "tangle.web"
  121.  
  122. /*:12*/
  123. #line 46 "tangle.web"
  124.  
  125. /*14:*/
  126. #line 107 "tangle.web"
  127.  
  128. #line 108 "tangle.web"
  129. typedef struct{
  130. eight_bits *tok_start;
  131. sixteen_bits text_link;
  132. }text;
  133. typedef text *text_pointer;
  134.  
  135. /*:14*//*25:*/
  136. #line 254 "tangle.web"
  137.  
  138. typedef struct{
  139. eight_bits *end_field;
  140. eight_bits *byte_field;
  141. name_pointer name_field;
  142. text_pointer repl_field;
  143. sixteen_bits mod_field;
  144. }output_state;
  145. typedef output_state *stack_pointer;
  146.  
  147. /*:25*/
  148. #line 47 "tangle.web"
  149.  
  150. /*15:*/
  151. #line 114 "tangle.web"
  152.  
  153. #line 115 "tangle.web"
  154. text text_info[2000];
  155. text_pointer text_info_end= text_info+2000-1;
  156. text_pointer text_ptr;
  157. eight_bits tok_mem[150000];
  158. eight_bits *tok_mem_end= tok_mem+150000-1;
  159. eight_bits *tok_ptr;
  160.  
  161. /*:15*//*21:*/
  162. #line 185 "tangle.web"
  163.  
  164. text_pointer last_unnamed;
  165.  
  166. /*:21*//*26:*/
  167. #line 270 "tangle.web"
  168.  
  169. output_state cur_state;
  170.  
  171. output_state stack[50+1];
  172. stack_pointer stack_ptr;
  173. stack_pointer stack_end= stack+50;
  174.  
  175. /*:26*//*37:*/
  176. #line 413 "tangle.web"
  177.  
  178. int cur_val;
  179.  
  180.  
  181. /*:37*//*46:*/
  182. #line 520 "tangle.web"
  183.  
  184. #line 521 "tangle.web"
  185. short balances[128];
  186. /*:46*//*50:*/
  187. #line 583 "tangle.web"
  188.  
  189. #line 584 "tangle.web"
  190. name_pointer parm_ptr;
  191.  
  192. /*:50*//*62:*/
  193. #line 706 "tangle.web"
  194.  
  195. eight_bits out_state;
  196. boolean protect;
  197.  
  198. /*:62*//*64:*/
  199. #line 735 "tangle.web"
  200.  
  201. name_pointer output_files[256];
  202. name_pointer *cur_out_file, *end_output_files, *an_output_file;
  203. char cur_module_char;
  204. char output_file_name[400];
  205.  
  206. /*:64*//*78:*/
  207. #line 143 "outtoks.web"
  208. char C_file_extension[]= "c";
  209. /*:78*//*80:*/
  210. #line 148 "outtoks.web"
  211. char the_at_sign= 64;
  212.  
  213. /*:80*//*86:*/
  214. #line 943 "tangle.web"
  215.  
  216. eight_bits ccode[128];
  217.  
  218. /*:86*//*88:*/
  219. #line 975 "tangle.web"
  220. short tracing;
  221. #line 976 "tangle.web"
  222. /*:88*//*91:*/
  223. #line 1009 "tangle.web"
  224.  
  225. #line 1010 "tangle.web"
  226. boolean comment_continues= 0;
  227.  
  228. /*:91*//*93:*/
  229. #line 1043 "tangle.web"
  230.  
  231. name_pointer cur_module;
  232.  
  233. /*:93*//*108:*/
  234. #line 1310 "tangle.web"
  235.  
  236. text_pointer cur_text;
  237. eight_bits next_control;
  238.  
  239. /*:108*//*111:*/
  240. #line 1373 "tangle.web"
  241.  
  242. ASCII param_name_texts[256];
  243. ASCII *param_name_texts_end= param_name_texts+256;
  244. ASCII *param_names[32];
  245. short next_param_name;
  246. ASCII *next_param_name_text;
  247.  
  248. /*:111*//*132:*/
  249. #line 1693 "tangle.web"
  250.  
  251. #line 1694 "tangle.web"
  252. extern sixteen_bits module_count;
  253.  
  254. /*:132*/
  255. #line 48 "tangle.web"
  256.  
  257.  
  258. main(ac,av)
  259. char * *av;
  260. {
  261. argc= ac;argv= av;
  262. program= 0;
  263. /*16:*/
  264. #line 122 "tangle.web"
  265.  
  266. #line 123 "tangle.web"
  267. text_info->tok_start= tok_ptr= tok_mem;
  268. text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
  269.  
  270.  
  271. /*:16*//*18:*/
  272. #line 132 "tangle.web"
  273.  
  274. name_dir->equiv_or_xref= (ASCII *)text_info;
  275.  
  276. /*:18*//*22:*/
  277. #line 188 "tangle.web"
  278. last_unnamed= text_info;text_info->text_link= 0;
  279. #line 189 "tangle.web"
  280.  
  281. /*:22*//*47:*/
  282. #line 522 "tangle.web"
  283.  
  284. #line 523 "tangle.web"
  285. {int i;
  286. for(i= 0;i<128;i++)balances[i]= 0;
  287. /*48:*/
  288. #line 529 "tangle.web"
  289.  
  290. #line 530 "tangle.web"
  291. balances[40]= 1;
  292. balances[41]= -1;
  293. balances[91]= 1;
  294. balances[93]= -1;
  295. balances[123]= 1;
  296. balances[125]= -1;
  297.  
  298. /*:48*/
  299. #line 525 "tangle.web"
  300. ;
  301. }
  302. /*:47*//*65:*/
  303. #line 745 "tangle.web"
  304.  
  305. #line 746 "tangle.web"
  306. cur_out_file= end_output_files= output_files+256;
  307.  
  308. /*:65*//*87:*/
  309. #line 946 "tangle.web"
  310. {
  311. #line 947 "tangle.web"
  312. int c;
  313. for(c= 0;c<=127;c++)ccode[c]= 0;
  314. ccode[' ']= ccode[011]= ccode['*']= 255;
  315. ccode['@']= '@';
  316. ccode['=']= 2;
  317. ccode['d']= ccode['D']= 252;
  318. ccode['f']= ccode['F']= 251;
  319. ccode['c']= ccode['C']= 253;
  320. ccode['u']= ccode['U']= 253;
  321. ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']= 250;
  322. ccode['&']= 127;
  323. ccode['<']= ccode['(']= 254;
  324. ccode['`']= 249;
  325. ccode['\'']= 5;
  326. ccode['"']= 6;
  327.  
  328.  
  329.  
  330. ccode['@']= ccode[64];
  331. ccode[64]= 64;
  332.  
  333. #ifdef DEBUG
  334. ccode['0']= ccode['1']= ccode['2']= ccode['3']= ccode['4']= 248;
  335. #endif DEBUG
  336.  
  337. }
  338.  
  339. /*:87*//*89:*/
  340. #line 976 "tangle.web"
  341. tracing= 0;
  342. #line 977 "tangle.web"
  343.  
  344. /*:89*//*104:*/
  345. #line 1239 "tangle.web"
  346. mod_text[0]= ' ';
  347. #line 1240 "tangle.web"
  348.  
  349. /*:104*//*113:*/
  350. #line 1385 "tangle.web"
  351. /*112:*/
  352. #line 1380 "tangle.web"
  353.  
  354. #line 1381 "tangle.web"
  355. next_param_name= 0;
  356. next_param_name_text= param_name_texts;
  357. param_names[next_param_name]= next_param_name_text;
  358.  
  359. /*:112*/
  360. #line 1385 "tangle.web"
  361. ;
  362. #line 1386 "tangle.web"
  363.  
  364. /*:113*/
  365. #line 55 "tangle.web"
  366. ;
  367. common_init();
  368. printf("This is C TANGLE (generated at 5:29 PM on April 5, 1993)\n");
  369. phase_one();
  370. phase_two();
  371. wrap_up();
  372. }
  373.  
  374. /*:1*//*19:*/
  375. #line 138 "tangle.web"
  376.  
  377. #line 139 "tangle.web"
  378. names_match(p,first,l)
  379. name_pointer p;
  380. ASCII *first;
  381. int l;
  382. {
  383. if(((p+1)->byte_start-(p)->byte_start)!=l)return 0;
  384. return!strncmp(first,p->byte_start,l);
  385. }
  386.  
  387. /*:19*//*20:*/
  388. #line 149 "tangle.web"
  389.  
  390. #line 150 "tangle.web"
  391. init_node(node)
  392. name_pointer node;
  393. {
  394. node->equiv_or_xref= (ASCII *)text_info;
  395.  
  396. }
  397. init_p(p,t)
  398. name_pointer p;
  399. eight_bits t;
  400. {
  401. p->dummy.Ilk= t;
  402. }
  403.  
  404.  
  405.  
  406. /*:20*//*24:*/
  407. #line 219 "tangle.web"
  408. store_two_bytes(x)
  409. sixteen_bits x;
  410. {
  411. if(tok_ptr+2>tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};};
  412.  *tok_ptr++= x>>8;
  413.  *tok_ptr++= x&255;
  414. }
  415.  
  416.  
  417. /*:24*//*28:*/
  418. #line 294 "tangle.web"
  419. push_level(p)
  420. #line 295 "tangle.web"
  421. name_pointer p;
  422. {
  423. /*29:*/
  424. #line 306 "tangle.web"
  425.  
  426. #line 307 "tangle.web"
  427. #ifdef TRACE_MACROS
  428. if(tracing>0){
  429. printf("\nPushing ");fflush(stdout),write(1,(p)->byte_start,(((p)+1)->byte_start-((p))->byte_start));
  430. printf(" =nd[%d]",p-name_dir);
  431. }
  432. #endif TRACE_MACROS
  433.  
  434. /*:29*/
  435. #line 297 "tangle.web"
  436. ;
  437. if(stack_ptr==stack_end){{printf("\n! Sorry, capacity exceeded: ");err_print("stack");history= 3;wrap_up();};};
  438.  *stack_ptr= cur_state;
  439. stack_ptr++;
  440. cur_state.name_field= p;cur_state.repl_field= (text_pointer)p->equiv_or_xref;
  441. cur_state.byte_field= cur_state.repl_field->tok_start;cur_state.end_field= (cur_state.repl_field+1)->tok_start;
  442. cur_state.mod_field= 0;
  443. }
  444.  
  445. /*:28*//*30:*/
  446. #line 321 "tangle.web"
  447. pop_level()
  448. #line 322 "tangle.web"
  449. {int number_of_parameters;
  450. /*33:*/
  451. #line 363 "tangle.web"
  452.  
  453. #line 364 "tangle.web"
  454. #ifdef TRACE_MACROS
  455. if(tracing>0){
  456. printf("\nPopping ");fflush(stdout),write(1,(cur_state.name_field)->byte_start,(((cur_state.name_field)+1)->byte_start-((cur_state.name_field))->byte_start));
  457. printf(" =nd[%d]",cur_state.name_field-name_dir);
  458. }
  459.  
  460. #endif TRACE_MACROS
  461.  
  462.  
  463.  
  464. /*:33*/
  465. #line 323 "tangle.web"
  466. ;
  467. if(cur_state.repl_field->text_link==0){
  468. if(cur_state.name_field->dummy.Ilk==1){
  469. /*31:*/
  470. #line 338 "tangle.web"
  471.  
  472. #line 339 "tangle.web"
  473. number_of_parameters=  *(cur_state.repl_field->tok_start);
  474. /*32:*/
  475. #line 357 "tangle.web"
  476.  
  477. #line 358 "tangle.web"
  478. #ifdef TRACE_MACROS
  479. if(tracing>1){
  480. printf("\nUnstacking %d parameters",number_of_parameters);
  481. }
  482. #endif TRACE_MACROS
  483. /*:32*/
  484. #line 340 "tangle.web"
  485. ;
  486. while(number_of_parameters-->0){
  487. name_ptr--;text_ptr--;
  488. #ifdef TRACE_MACROS
  489. byte_ptr-= 2;
  490. #endif TRACE_MACROS
  491. }
  492. #ifdef STAT
  493. #ifdef STAT_HAS_BEEN_FIXED
  494. if(tok_ptr>max_tok_ptr)max_tok_ptr= tok_ptr;
  495.  
  496.  
  497. #endif STAT_HAS_BEEN_FIXED
  498. #endif STAT
  499. tok_ptr= text_ptr->tok_start;
  500.  
  501.  
  502. /*:31*/
  503. #line 326 "tangle.web"
  504. ;
  505. }
  506. }else if(cur_state.repl_field->text_link<2000){
  507. cur_state.repl_field= cur_state.repl_field->text_link+text_info;
  508. cur_state.byte_field= cur_state.repl_field->tok_start;cur_state.end_field= (cur_state.repl_field+1)->tok_start;
  509. return;
  510. }
  511. stack_ptr--;
  512. if(stack_ptr>stack)cur_state=  *stack_ptr;
  513. }
  514.  
  515.  
  516. /*:30*//*38:*/
  517. #line 418 "tangle.web"
  518. sixteen_bits
  519. #line 419 "tangle.web"
  520.  get_output()
  521. {
  522. sixteen_bits a;
  523. restart:if(stack_ptr==stack)return 0;
  524. if(cur_state.byte_field==cur_state.end_field){
  525. cur_val= -((int)cur_state.mod_field);
  526. pop_level();
  527. if(cur_val==0)goto restart;
  528. out_char(129);return;
  529. }
  530. a=  *cur_state.byte_field++;
  531. if(a<128)
  532. if(a==7){
  533. /*40:*/
  534. #line 454 "tangle.web"
  535.  
  536. #line 455 "tangle.web"
  537. #ifdef TRACE_MACROS
  538. if(tracing>2){
  539. printf(" [#%d]", *cur_state.byte_field);
  540. }
  541. #endif TRACE_MACROS
  542.  
  543. /*:40*/
  544. #line 432 "tangle.web"
  545. ;
  546. /*39:*/
  547. #line 452 "tangle.web"
  548.  
  549. #line 453 "tangle.web"
  550. push_level(name_ptr- *cur_state.byte_field++);goto restart;
  551. /*:39*/
  552. #line 434 "tangle.web"
  553. ;
  554. }else
  555. out_char(a);
  556. else{
  557. a= (a-128) *256+ *cur_state.byte_field++;
  558. switch(a/10240){
  559. case 0:
  560. /*41:*/
  561. #line 461 "tangle.web"
  562.  
  563. #line 462 "tangle.web"
  564. if(name_dir[a].dummy.Ilk==1){
  565. /*42:*/
  566. #line 475 "tangle.web"
  567.  
  568. #line 476 "tangle.web"
  569. #ifdef TRACE_MACROS
  570. if(tracing>2){
  571. printf("\nExpanding macro (");fflush(stdout),write(1,(name_dir+a)->byte_start,(((name_dir+a)+1)->byte_start-((name_dir+a))->byte_start));
  572. printf("=nd[%d])",a);
  573. }
  574. #endif TRACE_MACROS
  575.  
  576. /*:42*/
  577. #line 463 "tangle.web"
  578. ;
  579. /*44:*/
  580. #line 492 "tangle.web"
  581.  
  582. #line 493 "tangle.web"
  583. {int number_of_parameters;
  584. while(cur_state.byte_field==cur_state.end_field&&stack_ptr>stack)pop_level();
  585. number_of_parameters=  *(((text_pointer)name_dir[a].equiv_or_xref)->tok_start);
  586. if(number_of_parameters>0){
  587. if(stack_ptr==stack|| *cur_state.byte_field!=40){
  588. printf("\n! No parameters given for ");
  589. fflush(stdout),write(1,(a+name_dir)->byte_start,(((a+name_dir)+1)->byte_start-((a+name_dir))->byte_start));
  590. err_print("");
  591. goto restart;
  592. }
  593. cur_state.byte_field++;
  594. parm_ptr= name_ptr;
  595. while(number_of_parameters-->0){
  596. /*49:*/
  597. #line 537 "tangle.web"
  598.  
  599. #line 538 "tangle.web"
  600. {int bal;
  601. eight_bits b,oldb;
  602. sixteen_bits c;
  603. bal= 0;
  604. /*59:*/
  605. #line 647 "tangle.web"
  606.  
  607. #line 648 "tangle.web"
  608. #ifdef TRACE_MACROS
  609. if(tracing>2){
  610. printf("\nScanning #%d...",number_of_parameters+1);
  611. }
  612. #endif TRACE_MACROS
  613. /*:59*/
  614. #line 542 "tangle.web"
  615. ;
  616. while(1){
  617. b=  *cur_state.byte_field++;
  618. if(b==7){
  619. b=  *cur_state.byte_field++;
  620. /*56:*/
  621. #line 613 "tangle.web"
  622.  
  623. #line 614 "tangle.web"
  624. #ifdef TRACE_MACROS
  625. if(tracing>2){
  626. printf(" <#%d=",b);fflush(stdout),write(1,(name_ptr-b)->byte_start,(((name_ptr-b)+1)->byte_start-((name_ptr-b))->byte_start));printf("=nd[%d]>",
  627. name_ptr-b-name_dir);
  628. }
  629. #endif TRACE_MACROS
  630.  
  631. /*:56*/
  632. #line 547 "tangle.web"
  633. ;
  634. c= name_ptr-name_dir-b;
  635. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 128+(c/256);};
  636. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= c%256;};
  637. }else{
  638. if(b>=128){
  639. /*57:*/
  640. #line 621 "tangle.web"
  641.  
  642. #line 622 "tangle.web"
  643. #ifdef TRACE_MACROS
  644. if(tracing>2){
  645. int c;
  646. printf(" <");
  647. c= (b-128) *256+ *cur_state.byte_field;
  648. switch(c/10240){
  649. case 0:fflush(stdout),write(1,(name_dir+c)->byte_start,(((name_dir+c)+1)->byte_start-((name_dir+c))->byte_start));
  650. printf(" =nd[%d]",c);
  651. break;
  652. case 1:printf("MODULE");break;
  653. default:printf("CONTEXT");break;
  654. }
  655. printf(">");
  656. }
  657. #endif TRACE_MACROS
  658.  
  659. /*:57*/
  660. #line 553 "tangle.web"
  661. ;
  662. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= b;};
  663. b=  *cur_state.byte_field++;
  664. }else if(bal==0&&((number_of_parameters==0&&b==41)
  665. ||(number_of_parameters>0&&b==44))){
  666. goto done;
  667. }else if(/*51:*/
  668. #line 586 "tangle.web"
  669. (b==2||b==3)
  670. #line 587 "tangle.web"
  671. /*:51*/
  672. #line 559 "tangle.web"
  673. ){
  674. /*52:*/
  675. #line 587 "tangle.web"
  676.  
  677. #line 588 "tangle.web"
  678. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= b;};
  679. oldb= b;
  680. /*53:*/
  681. #line 601 "tangle.web"
  682.  
  683. #line 602 "tangle.web"
  684. #ifdef TRACE_MACROS
  685. if(tracing>2)printf(" <");
  686. #endif TRACE_MACROS
  687. /*:53*/
  688. #line 590 "tangle.web"
  689. ;
  690. while((b=  *cur_state.byte_field++)!=oldb){
  691. /*54:*/
  692. #line 605 "tangle.web"
  693.  
  694. #line 606 "tangle.web"
  695. #ifdef TRACE_MACROS
  696. if(tracing>2)printf("%c",b);
  697. #endif TRACE_MACROS
  698. /*:54*/
  699. #line 592 "tangle.web"
  700. ;
  701. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= b;};
  702. if(cur_state.byte_field>=cur_state.end_field)
  703. {printf("\n! This can't happen: ");err_print("string or constant didn't end in token list");history= 3;wrap_up();};
  704. }
  705. /*55:*/
  706. #line 609 "tangle.web"
  707.  
  708. #line 610 "tangle.web"
  709. #ifdef TRACE_MACROS
  710. if(tracing>2)printf(">");
  711. #endif TRACE_MACROS
  712. /*:55*/
  713. #line 597 "tangle.web"
  714. ;
  715.  
  716.  
  717.  
  718. /*:52*/
  719. #line 560 "tangle.web"
  720. ;
  721. }else{
  722. /*58:*/
  723. #line 638 "tangle.web"
  724.  
  725. #line 639 "tangle.web"
  726. #ifdef TRACE_MACROS
  727. if(tracing>2){
  728. printf(" <");
  729. if(31<b&&b<127)printf("%c",b);
  730. printf(">");
  731. }
  732. #endif TRACE_MACROS
  733.  
  734. /*:58*/
  735. #line 562 "tangle.web"
  736. ;
  737. bal+= balances[b];
  738. }
  739. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= b;};
  740. }
  741. }
  742. done:
  743. parm_ptr->equiv_or_xref= (ASCII *)text_ptr;
  744. text_ptr->text_link= 0;
  745. parm_ptr->dummy.Ilk= 2;
  746. #ifdef TRACE_MACROS
  747. if(byte_ptr+2>=byte_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("byte memory");history= 3;wrap_up();};};
  748.  *byte_ptr++= 35; *byte_ptr++= number_of_parameters+1+48;
  749. #endif TRACE_MACROS
  750. if(parm_ptr>=name_dir_end){{printf("\n! Sorry, capacity exceeded: ");err_print("name");history= 3;wrap_up();};};
  751. (++parm_ptr)->byte_start= byte_ptr;
  752. if(text_ptr>=text_info_end){{printf("\n! Sorry, capacity exceeded: ");err_print("text");history= 3;wrap_up();};};
  753. (++text_ptr)->tok_start= tok_ptr;
  754. /*60:*/
  755. #line 653 "tangle.web"
  756.  
  757. #line 654 "tangle.web"
  758. #ifdef TRACE_MACROS
  759. if(tracing>1){
  760. printf("\nStacked ");fflush(stdout),write(1,(parm_ptr-1)->byte_start,(((parm_ptr-1)+1)->byte_start-((parm_ptr-1))->byte_start));
  761. printf("=nd[%d]",parm_ptr-1-name_dir);
  762. }
  763. #endif TRACE_MACROS
  764.  
  765. /*:60*/
  766. #line 580 "tangle.web"
  767. ;
  768. }
  769.  
  770. /*:49*/
  771. #line 507 "tangle.web"
  772. ;
  773. }
  774. name_ptr= parm_ptr;
  775.  
  776. }
  777. }
  778.  
  779. /*:44*/
  780. #line 465 "tangle.web"
  781. ;
  782. push_level(name_dir+a);
  783. cur_state.byte_field++;
  784. goto restart;
  785. }else if(name_dir[a].dummy.Ilk==2){
  786. /*43:*/
  787. #line 483 "tangle.web"
  788.  
  789. #line 484 "tangle.web"
  790. #ifdef TRACE_MACROS
  791. if(tracing>2){
  792. printf("\nExpanding parameter (");fflush(stdout),write(1,(name_dir+a)->byte_start,(((name_dir+a)+1)->byte_start-((name_dir+a))->byte_start));
  793. printf("=nd[%d])",a);
  794. }
  795. #endif TRACE_MACROS
  796.  
  797.  
  798. /*:43*/
  799. #line 470 "tangle.web"
  800. ;
  801. push_level(name_dir+a);
  802. goto restart;
  803. }
  804.  
  805. /*:41*/
  806. #line 441 "tangle.web"
  807. ;
  808. cur_val= a;out_char(130);break;
  809. case 1:/*61:*/
  810. #line 664 "tangle.web"
  811.  
  812. #line 665 "tangle.web"
  813. a-= 10240;
  814. if((a+name_dir)->equiv_or_xref!=(ASCII *)text_info)push_level(a+name_dir);
  815. else if(a!=0){
  816. printf("\n! Not present: <");fflush(stdout),write(1,(a+name_dir)->byte_start,(((a+name_dir)+1)->byte_start-((a+name_dir))->byte_start));err_print(">");
  817.  
  818. }
  819. goto restart;
  820.  
  821. /*:61*/
  822. #line 443 "tangle.web"
  823. ;
  824. default:cur_val= a-20480;if(cur_val>0)cur_state.mod_field= cur_val;
  825. out_char(129);
  826. }
  827. }
  828. return 1;
  829. }
  830.  
  831.  
  832. /*:38*//*63:*/
  833. #line 714 "tangle.web"
  834. flush_buffer()
  835. #line 715 "tangle.web"
  836. {
  837. putc('\n',C_file);
  838. if(line[include_depth]%100==0){
  839. printf(".");
  840. if(line[include_depth]%500==0)printf("%d",line[include_depth]);
  841. fflush(stdout);
  842. }
  843. line[include_depth]++;
  844. }
  845.  
  846. /*:63*//*67:*/
  847. #line 764 "tangle.web"
  848.  
  849. #line 765 "tangle.web"
  850. phase_two(){
  851. line[include_depth]= 1;
  852. if(text_info->text_link==0){
  853. if(end_output_files==cur_out_file){
  854. printf("\n! No program text was specified.");{if(history==0)history= 1;};
  855.  
  856. }
  857. }else{
  858. printf("\nWriting the output files: (%s)",C_file_name);fflush(stdout);
  859. /*27:*/
  860. #line 283 "tangle.web"
  861.  
  862. #line 284 "tangle.web"
  863. stack_ptr= stack+1;cur_state.name_field= name_dir;cur_state.repl_field= text_info->text_link+text_info;
  864. cur_state.byte_field= cur_state.repl_field->tok_start;cur_state.end_field= (cur_state.repl_field+1)->tok_start;cur_state.mod_field= 0;
  865.  
  866. /*:27*/
  867. #line 774 "tangle.web"
  868. ;
  869. while(stack_ptr>stack)get_output();
  870. flush_buffer();
  871. }
  872. if(end_output_files>cur_out_file){
  873. if(text_info->text_link==0){
  874. printf("\nWriting the output files: ");fflush(stdout);
  875. }
  876. /*68:*/
  877. #line 790 "tangle.web"
  878.  
  879. #line 791 "tangle.web"
  880. for(an_output_file= end_output_files;an_output_file>cur_out_file;){
  881. an_output_file--;
  882. strncpy(output_file_name,( *an_output_file)->byte_start,400);
  883. output_file_name[(( *an_output_file+1)->byte_start-( *an_output_file)->byte_start)]= '\0';
  884. fclose(C_file);
  885. C_file= fopen(output_file_name,"w");
  886. if(C_file==NULL){
  887. {printf("! Cannot open output file:");err_print(output_file_name);history= 3;wrap_up();}
  888. }else{
  889. printf(" (%s)",output_file_name);fflush(stdout);
  890. }
  891. stack_ptr= stack+1;
  892. cur_state.name_field= ( *an_output_file);
  893. cur_state.repl_field= (text_pointer)cur_state.name_field->equiv_or_xref;
  894. cur_state.byte_field= cur_state.repl_field->tok_start;
  895. cur_state.end_field= (cur_state.repl_field+1)->tok_start;
  896. cur_state.mod_field= 0;
  897. while(stack_ptr>stack)get_output();
  898. flush_buffer();
  899. }
  900.  
  901.  
  902.  
  903. /*:68*/
  904. #line 782 "tangle.web"
  905.  
  906. }
  907. printf("\nDone.");
  908. }
  909.  
  910. /*:67*//*69:*/
  911. #line 816 "tangle.web"
  912. out_char(cur_char)
  913. #line 817 "tangle.web"
  914. eight_bits cur_char;
  915. {
  916. ASCII *j;
  917. /*70:*/
  918. #line 841 "tangle.web"
  919.  
  920. #line 842 "tangle.web"
  921. #ifdef TRACE_MACROS
  922. if(tracing>2){
  923. switch(cur_char){
  924. case 10:printf(" [\\n]");break;
  925. case 2:
  926. printf("[STRING]");break;
  927. case 127:
  928. printf("[JOIN]");break;
  929. case 3:
  930. printf("[CONSTANT]");break;
  931. case 130:
  932. printf(" [");fflush(stdout),write(1,(cur_val+name_dir)->byte_start,(((cur_val+name_dir)+1)->byte_start-((cur_val+name_dir))->byte_start));printf("]");
  933. break;
  934. case 129:
  935. if(cur_val>0){
  936. printf(" [%d:]",cur_val);
  937. }else if(cur_val<0){
  938. printf(" [:%d]",-cur_val);
  939. }else{
  940. printf("[LINE NUMBER]");
  941. }
  942. break;
  943.  
  944. default:
  945. if(31<cur_char&&cur_char<127){
  946. printf(" [%c]",cur_char);
  947. }else{
  948. printf(" [\\%3o]",cur_char);
  949. }
  950. }
  951. }
  952. #endif TRACE_MACROS
  953.  
  954.  
  955.  
  956.  
  957. /*:70*/
  958. #line 820 "tangle.web"
  959. ;
  960. switch(cur_char){
  961. case 10:if(protect)putc(' ',C_file);
  962. if(protect||out_state==4)putc('\\',C_file);
  963.  
  964. flush_buffer();if(out_state!=4)out_state= 0;break;
  965. /*71:*/
  966. #line 878 "tangle.web"
  967.  
  968. #line 879 "tangle.web"
  969. case 130:
  970. if(out_state==1)putc(' ',C_file);
  971. for(j= (cur_val+name_dir)->byte_start;j<(name_dir+cur_val+1)->byte_start;
  972. j++)putc( *j,C_file);
  973. out_state= 1;break;
  974.  
  975. /*:71*/
  976. #line 826 "tangle.web"
  977. ;
  978. /*72:*/
  979. #line 885 "tangle.web"
  980.  
  981. #line 886 "tangle.web"
  982. case 129:
  983. if(cur_val>0){
  984. fprintf(C_file,"%s","/*");
  985. fprintf(C_file,"%d:",cur_val);
  986. fprintf(C_file,"%s","*/");
  987. }else if(cur_val<0){
  988. fprintf(C_file,"%s","/*");
  989. fprintf(C_file,":%d",-cur_val);
  990. fprintf(C_file,"%s","*/");
  991. }else{
  992. sixteen_bits a;
  993. a= 256 * *cur_state.byte_field++;
  994. a+=  *cur_state.byte_field++;
  995. fprintf(C_file,"\n%s","#line");
  996. fprintf(C_file," %d \"",a);
  997. cur_val=  *cur_state.byte_field++;
  998. cur_val= 256 *(cur_val-128)+ *cur_state.byte_field++;
  999. for(j= (cur_val+name_dir)->byte_start;j<(name_dir+cur_val+1)->byte_start;
  1000. j++)putc( *j,C_file);
  1001. fprintf(C_file,"\"%s\n",""
  1002. #line 910 "tangle.web"
  1003. );
  1004. }
  1005. break;
  1006.  
  1007. #line 1 "outtoks.web"
  1008. /*:72*/
  1009. #line 827 "tangle.web"
  1010. ;
  1011. /*75:*/
  1012. #line 58 "outtoks.web"
  1013.  
  1014. #line 59 "outtoks.web"
  1015. case 26:
  1016. fprintf(C_file,"%s","==");
  1017. if(out_state!=4)out_state= 0;
  1018. break;
  1019. case 23:
  1020. fprintf(C_file,"%s","->");
  1021. if(out_state!=4)out_state= 0;
  1022. break;
  1023. case 25:
  1024. fprintf(C_file,"%s","&&");
  1025. if(out_state!=4)out_state= 0;
  1026. break;
  1027. case 24:
  1028. fprintf(C_file,"%s","||");
  1029. if(out_state!=4)out_state= 0;
  1030. break;
  1031. case 21:
  1032. fprintf(C_file,"%s","<<");
  1033. if(out_state!=4)out_state= 0;
  1034. break;
  1035. case 28:
  1036. fprintf(C_file,"%s","<=");
  1037. if(out_state!=4)out_state= 0;
  1038. break;
  1039. case 20:
  1040. if(out_state==4){
  1041. fprintf(C_file,"%s","===>");
  1042. }else{
  1043. fprintf(C_file,"%s"," ");
  1044. }
  1045. if(out_state!=4)out_state= 0;
  1046. break;
  1047. case 31:
  1048. fprintf(C_file,"%s","++");
  1049. if(out_state!=4)out_state= 0;
  1050. break;
  1051. case 27:
  1052. fprintf(C_file,"%s",">=");
  1053. if(out_state!=4)out_state= 0;
  1054. break;
  1055. case 22:
  1056. fprintf(C_file,"%s",">>");
  1057. if(out_state!=4)out_state= 0;
  1058. break;
  1059. case 29:
  1060. fprintf(C_file,"%s","!=");
  1061. if(out_state!=4)out_state= 0;
  1062. break;
  1063. case 30:
  1064. fprintf(C_file,"%s","--");
  1065. if(out_state!=4)out_state= 0;
  1066. break;
  1067. /*:75*//*76:*/
  1068. #line 111 "outtoks.web"
  1069.  
  1070. #line 112 "outtoks.web"
  1071. case'=':
  1072. if(out_state==4){
  1073. fprintf(C_file,"%s","=");
  1074. }else{
  1075. fprintf(C_file,"%s","= ");
  1076. }
  1077. if(out_state!=4)out_state= 0;
  1078. break;
  1079. case'*':
  1080. if(out_state==4){
  1081. fprintf(C_file,"%s","*");
  1082. }else{
  1083. fprintf(C_file,"%s"," *");
  1084. }
  1085. if(out_state!=4)out_state= 0;
  1086. break;
  1087. /*:76*/
  1088. #line 828 "tangle.web"
  1089.  
  1090. case 127:out_state= 3;break;
  1091. case 3:if(out_state==4){
  1092. out_state= 1;break;
  1093. }
  1094. if(out_state==1)putc(' ',C_file);out_state= 4;break;
  1095. case 2:if(out_state==4)out_state= 0;
  1096. else out_state= 4;break;
  1097. default:putc(cur_char,C_file);if(out_state!=4)out_state= 0;
  1098. break;
  1099. }
  1100. }
  1101.  
  1102. /*:69*//*90:*/
  1103. #line 981 "tangle.web"
  1104. eight_bits skip_ahead()
  1105. #line 982 "tangle.web"
  1106. {
  1107. eight_bits c;
  1108. while(1){
  1109. if(loc>limit&&(get_line()==0))return(255);
  1110.  *(limit+1)= 64;
  1111. while( *loc!=64)loc++;
  1112. if(loc<=limit){
  1113. loc++;c= ccode[ *loc];
  1114. #ifdef DEBUG
  1115. if(c==248){
  1116. tracing=  *loc-48;c= 0;
  1117. }
  1118. #endif DEBUG
  1119. loc++;
  1120. if(c!=0|| *(loc-1)=='>')return(c);
  1121. }
  1122. }
  1123. }
  1124.  
  1125. /*:90*//*92:*/
  1126. #line 1012 "tangle.web"
  1127.  
  1128. #line 1013 "tangle.web"
  1129. skip_comment()
  1130. {
  1131. ASCII c;
  1132. if(0){
  1133. get_line();
  1134. return(comment_continues= 0);
  1135. }else{
  1136. while(1){
  1137. if(loc>limit)
  1138. if(get_line())return(comment_continues= 1);
  1139. else{
  1140. err_print("! Input ended in mid-comment");
  1141.  
  1142. return(comment_continues= 0);
  1143. }
  1144. c=  *(loc++);
  1145. /*82:*/
  1146. #line 163 "outtoks.web"
  1147.  
  1148. {int len;len= strlen("*/");
  1149. if(loc+len-1<=limit&&!strncmp(loc-1,"*/",len)){
  1150. loc+= len-1;return(comment_continues= 0);}}
  1151. /*:82*/
  1152. #line 1029 "tangle.web"
  1153.  
  1154. if(c==64){
  1155. if(ccode[ *loc]==255){
  1156. err_print("! Section name ended in mid-comment");loc--;
  1157.  
  1158. return(comment_continues= 0);
  1159. }
  1160. else loc++;
  1161. }
  1162. }
  1163. }
  1164. }
  1165. /*:92*//*95:*/
  1166. #line 1052 "tangle.web"
  1167. eight_bits get_next()
  1168. #line 1053 "tangle.web"
  1169. {
  1170. eight_bits c;
  1171. while(1){
  1172. if(loc>limit){
  1173. if(get_line()==0)return(255);
  1174. else if(print_where){
  1175. print_where= 0;
  1176. /*125:*/
  1177. #line 1586 "tangle.web"
  1178.  
  1179. #line 1587 "tangle.web"
  1180. store_two_bytes(53248);
  1181. if(changing)id_first= change_file_name;
  1182. else id_first= file_name[include_depth];
  1183. id_loc= id_first+strlen(id_first);
  1184. if(changing)store_two_bytes((sixteen_bits)change_line);
  1185. else store_two_bytes((sixteen_bits)line[include_depth]);
  1186. {int a= id_lookup(id_first,id_loc,0)-name_dir;{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= (a/256)+128;};
  1187. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a%256;};}
  1188.  
  1189. /*:125*/
  1190. #line 1060 "tangle.web"
  1191. ;
  1192. }
  1193. else return(10);
  1194. }
  1195. c=  *loc;
  1196. if(comment_continues){
  1197. skip_comment();
  1198. if(comment_continues||0)return(10);
  1199. else continue;
  1200. }
  1201. /*81:*/
  1202. #line 151 "outtoks.web"
  1203.  
  1204. #line 152 "outtoks.web"
  1205. {int len;len= strlen("/*");
  1206. if(loc+len<=limit&&!strncmp(loc,"/*",len)){
  1207. loc+= len;
  1208. skip_comment();
  1209. if(comment_continues||0)
  1210. return('\n');
  1211. else continue;
  1212. }
  1213. }
  1214. /*:81*/
  1215. #line 1070 "tangle.web"
  1216.  
  1217. loc++;
  1218. if(isdigit(c)||c=='\\'||c=='.')/*97:*/
  1219. #line 1092 "tangle.web"
  1220. {
  1221. #line 1093 "tangle.web"
  1222. id_first= loc-1;
  1223. if( *id_first=='.'&&!isdigit( *loc))goto mistake;
  1224. if( *id_first=='\\')while(isdigit( *loc))loc++;
  1225. else{
  1226. if( *id_first=='0'){
  1227. if( *loc=='x'|| *loc=='X'){
  1228. loc++;while(isxdigit( *loc))loc++;goto found;
  1229. }
  1230. }
  1231. while(isdigit( *loc))loc++;
  1232. if( *loc=='.'){
  1233. loc++;
  1234. while(isdigit( *loc))loc++;
  1235. }
  1236. if( *loc=='e'|| *loc=='E'){
  1237. if( *++loc=='+'|| *loc=='-')loc++;
  1238. while(isdigit( *loc))loc++;
  1239. }
  1240. }
  1241. found:
  1242. id_loc= loc;
  1243. return(3);
  1244. }
  1245.  
  1246. /*:97*/
  1247. #line 1072 "tangle.web"
  1248.  
  1249. else if(isalpha(c)||c=='_'||c=='$')/*96:*/
  1250. #line 1084 "tangle.web"
  1251. {
  1252. #line 1085 "tangle.web"
  1253. id_first= --loc;
  1254. while(isalpha( *++loc)||isdigit( *loc)|| *loc=='_');
  1255. if( *loc=='$')while(isdigit( *++loc)|| *loc=='$');
  1256.  
  1257. id_loc= loc;return(130);
  1258. }
  1259.  
  1260. /*:96*/
  1261. #line 1073 "tangle.web"
  1262.  
  1263. else if(c=='\''||c=='\"')/*98:*/
  1264. #line 1122 "tangle.web"
  1265. {
  1266. #line 1123 "tangle.web"
  1267. ASCII delim= c;
  1268.  
  1269.  
  1270. if(delim=='\''&&(loc+1>=limit||
  1271. ( *loc!='\\'&& *loc!=64&&loc[1]!='\'')||
  1272. ( *loc=='\\'&&(loc+2>=limit||loc[2]!='\''))||
  1273. ( *loc==64&&
  1274. (loc+2>=limit||loc[1]!=64||loc[2]!='\''))
  1275. ))goto mistake;
  1276. id_first= mod_text+1;
  1277. id_loc= mod_text; *++id_loc= delim;
  1278. while(1){
  1279. if(loc>=limit){
  1280. if( *(limit-1)!='\\'){
  1281. err_print("! String didn't end");loc= limit;break;
  1282.  
  1283. }
  1284. if(get_line()==0){
  1285. err_print("! Input ended in middle of string");loc= buffer;break;
  1286.  
  1287. }
  1288. else if(++id_loc<=mod_text_end) *id_loc= 10;
  1289.  
  1290. }
  1291. if((c=  *loc++)==delim){
  1292. if(++id_loc<=mod_text_end) *id_loc= c;
  1293. break;
  1294. }
  1295. if(c=='\\'){
  1296. if(loc>=limit)continue;
  1297. if(++id_loc<=mod_text_end) *id_loc= '\\';
  1298. c=  *loc++;
  1299. }
  1300. if(++id_loc<=mod_text_end) *id_loc= c;
  1301. }
  1302. if(id_loc>=mod_text_end){
  1303. printf("\n! String too long: ");
  1304.  
  1305. fflush(stdout),write(1,mod_text+1,25);
  1306. printf("...");history= 2;
  1307. }
  1308. id_loc++;
  1309. return(2);
  1310. }
  1311.  
  1312. /*:98*/
  1313. #line 1074 "tangle.web"
  1314.  
  1315. else if(c==64)/*99:*/
  1316. #line 1171 "tangle.web"
  1317. {
  1318. #line 1172 "tangle.web"
  1319. c= ccode[ *loc++];
  1320. switch(c){
  1321. case 0:continue;
  1322. case 250:while((c= skip_ahead())==64);
  1323.  
  1324. if( *(loc-1)!='>')err_print("! Improper @ within control text");
  1325.  
  1326. continue;
  1327. case 254:
  1328. cur_module_char=  *(loc-1);
  1329. /*103:*/
  1330. #line 1221 "tangle.web"
  1331. {
  1332. #line 1222 "tangle.web"
  1333. ASCII *k;
  1334. /*105:*/
  1335. #line 1241 "tangle.web"
  1336.  
  1337. #line 1242 "tangle.web"
  1338. k= mod_text;
  1339. while(1){
  1340. if(loc>limit&&get_line()==0){
  1341. err_print("! Input ended in section name");
  1342.  
  1343. loc= buffer+1;break;
  1344. }
  1345. c=  *loc;
  1346. /*106:*/
  1347. #line 1265 "tangle.web"
  1348.  
  1349. #line 1266 "tangle.web"
  1350. if(c==64){
  1351. c=  *(loc+1);
  1352. if(c=='>'){
  1353. loc+= 2;break;
  1354. }
  1355. if(ccode[c]==255){
  1356. err_print("! Section name didn't end");break;
  1357.  
  1358. }
  1359.  *(++k)= 64;loc++;
  1360. }
  1361.  
  1362. /*:106*/
  1363. #line 1250 "tangle.web"
  1364. ;
  1365. loc++;if(k<mod_text_end)k++;
  1366. if(c==' '||c==011){
  1367. c= ' ';if( *(k-1)==' ')k--;
  1368. }
  1369.  *k= c;
  1370. }
  1371. if(k>=mod_text_end){
  1372. printf("\n! Section name too long: ");
  1373.  
  1374. fflush(stdout),write(1,mod_text+1,25);
  1375. printf("...");{if(history==0)history= 1;};
  1376. }
  1377. if( *k==' '&&k>mod_text)k--;
  1378.  
  1379. /*:105*/
  1380. #line 1223 "tangle.web"
  1381. ;
  1382. if(k-mod_text>3&&strncmp(k-2,"...",3)==0)cur_module= prefix_lookup(mod_text+1,k-3);
  1383. else cur_module= mod_lookup(mod_text+1,k);
  1384. if(cur_module_char=='('){
  1385. /*66:*/
  1386. #line 749 "tangle.web"
  1387.  
  1388. #line 750 "tangle.web"
  1389. {
  1390. if(cur_out_file>output_files){
  1391. for(an_output_file= cur_out_file;
  1392. an_output_file<end_output_files;an_output_file++)
  1393. if( *an_output_file==cur_module)break;
  1394. if(an_output_file==end_output_files)
  1395.  *--cur_out_file= cur_module;
  1396. }else{
  1397. {{printf("\n! Sorry, capacity exceeded: ");err_print("output files");history= 3;wrap_up();};};
  1398. }
  1399. }
  1400.  
  1401. /*:66*/
  1402. #line 1228 "tangle.web"
  1403.  
  1404. }
  1405. return(254);
  1406. }
  1407.  
  1408. /*:103*/
  1409. #line 1182 "tangle.web"
  1410. ;
  1411. case 2:/*107:*/
  1412. #line 1283 "tangle.web"
  1413. {
  1414. #line 1284 "tangle.web"
  1415. id_first= loc++; *(limit+1)= 64; *(limit+2)= '>';
  1416. while( *loc!=64|| *(loc+1)!='>')loc++;
  1417. if(loc>=limit)err_print("! Verbatim string didn't end");
  1418.  
  1419. id_loc= loc;loc+= 2;
  1420. return(2);
  1421. }
  1422.  
  1423. /*:107*/
  1424. #line 1183 "tangle.web"
  1425. ;
  1426. #ifdef DEBUG
  1427. case 248:tracing=  *(loc-1)-'0';continue;
  1428. #endif DEBUG
  1429. case 249:/*100:*/
  1430. #line 1194 "tangle.web"
  1431.  
  1432. #line 1195 "tangle.web"
  1433. id_first= loc;
  1434. if( *loc=='\\')loc++;
  1435. while( *loc!='\''){
  1436. loc++;
  1437. if(loc>limit){
  1438. err_print("! String didn't end");loc= limit-1;break;
  1439. }
  1440. }
  1441. loc++;
  1442. return(249);
  1443.  
  1444. /*:100*/
  1445. #line 1187 "tangle.web"
  1446. ;
  1447. case 5:/*101:*/
  1448. #line 1206 "tangle.web"
  1449. {
  1450. #line 1207 "tangle.web"
  1451. id_first= loc;
  1452. while('0'<= *loc&& *loc<'8')loc++;
  1453. id_loc= loc;
  1454. return(5);
  1455. }
  1456.  
  1457. /*:101*/
  1458. #line 1188 "tangle.web"
  1459. ;
  1460. case 6:/*102:*/
  1461. #line 1213 "tangle.web"
  1462. {
  1463. #line 1214 "tangle.web"
  1464. id_first= loc;
  1465. while(isxdigit( *loc))loc++;
  1466. id_loc= loc;
  1467. return(6);
  1468. }
  1469.  
  1470.  
  1471. /*:102*/
  1472. #line 1189 "tangle.web"
  1473. ;
  1474. default:return(c);
  1475. }
  1476. }
  1477.  
  1478. /*:99*/
  1479. #line 1075 "tangle.web"
  1480.  
  1481. else if(c==' '||c==011){
  1482. continue;
  1483. }
  1484. mistake:/*74:*/
  1485. #line 3 "outtoks.web"
  1486.  
  1487. #line 4 "outtoks.web"
  1488. if(loc+3<=limit){
  1489. if(strncmp("===>",loc-1,4)==0){
  1490. loc+= 3;
  1491. return 20;
  1492. }
  1493. }
  1494. if(loc+2<=limit){
  1495. }
  1496. if(loc+1<=limit){
  1497. if(strncmp("==",loc-1,2)==0){
  1498. loc+= 1;
  1499. return 26;
  1500. }
  1501. else if(strncmp("->",loc-1,2)==0){
  1502. loc+= 1;
  1503. return 23;
  1504. }
  1505. else if(strncmp("&&",loc-1,2)==0){
  1506. loc+= 1;
  1507. return 25;
  1508. }
  1509. else if(strncmp("||",loc-1,2)==0){
  1510. loc+= 1;
  1511. return 24;
  1512. }
  1513. else if(strncmp("<<",loc-1,2)==0){
  1514. loc+= 1;
  1515. return 21;
  1516. }
  1517. else if(strncmp("<=",loc-1,2)==0){
  1518. loc+= 1;
  1519. return 28;
  1520. }
  1521. else if(strncmp("++",loc-1,2)==0){
  1522. loc+= 1;
  1523. return 31;
  1524. }
  1525. else if(strncmp(">=",loc-1,2)==0){
  1526. loc+= 1;
  1527. return 27;
  1528. }
  1529. else if(strncmp(">>",loc-1,2)==0){
  1530. loc+= 1;
  1531. return 22;
  1532. }
  1533. else if(strncmp("!=",loc-1,2)==0){
  1534. loc+= 1;
  1535. return 29;
  1536. }
  1537. else if(strncmp("--",loc-1,2)==0){
  1538. loc+= 1;
  1539. return 30;
  1540. }
  1541. }
  1542. /*:74*/
  1543. #line 1079 "tangle.web"
  1544.  
  1545. return(c);
  1546. }
  1547. }
  1548.  
  1549. /*:95*//*109:*/
  1550. #line 1314 "tangle.web"
  1551. scan_repl(t)
  1552. #line 1315 "tangle.web"
  1553. eight_bits t;
  1554. {
  1555. sixteen_bits a;
  1556. int set_print_where;
  1557. if(t==254){/*125:*/
  1558. #line 1586 "tangle.web"
  1559.  
  1560. #line 1587 "tangle.web"
  1561. store_two_bytes(53248);
  1562. if(changing)id_first= change_file_name;
  1563. else id_first= file_name[include_depth];
  1564. id_loc= id_first+strlen(id_first);
  1565. if(changing)store_two_bytes((sixteen_bits)change_line);
  1566. else store_two_bytes((sixteen_bits)line[include_depth]);
  1567. {int a= id_lookup(id_first,id_loc,0)-name_dir;{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= (a/256)+128;};
  1568. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a%256;};}
  1569.  
  1570. /*:125*/
  1571. #line 1319 "tangle.web"
  1572. ;}
  1573.  
  1574.  
  1575. while(1){
  1576. if(t==1){
  1577. print_where= 0;
  1578. }
  1579. a= get_next();
  1580. if(t==1){
  1581. set_print_where= print_where;
  1582. }
  1583. switch(a){
  1584. /*124:*/
  1585. #line 1529 "tangle.web"
  1586.  
  1587. #line 1530 "tangle.web"
  1588. case 130:
  1589. {short n;
  1590. if((n= parameter_number(id_first,id_loc))!=0){
  1591. #ifdef TRACE_MACROS
  1592. if(tracing>1){
  1593. printf("\nIdentified ");fflush(stdout),write(1,id_first,id_loc-id_first);
  1594. printf(" as parameter number %d (%d from back)",n,next_param_name-n+1);
  1595. }
  1596. #endif TRACE_MACROS
  1597. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 7;};
  1598. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= next_param_name-n+1;};
  1599. }else{
  1600. a= id_lookup(id_first,id_loc,0)-name_dir;
  1601. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= (a/256)+128;};{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a%256;};
  1602. }
  1603. }
  1604. break;
  1605. case 254:if(t!=254)goto done;
  1606. else{
  1607. /*126:*/
  1608. #line 1596 "tangle.web"
  1609. {
  1610. #line 1597 "tangle.web"
  1611. ASCII *try_loc= loc;
  1612. while( *try_loc==' '&&try_loc<limit)try_loc++;
  1613. if( *try_loc=='+'&&try_loc<limit)try_loc++;
  1614. while( *try_loc==' '&&try_loc<limit)try_loc++;
  1615. if( *try_loc=='=')err_print("! Nested named modules.  Missing @?");
  1616.  
  1617. }
  1618.  
  1619. /*:126*/
  1620. #line 1549 "tangle.web"
  1621. ;
  1622. a= cur_module-name_dir;
  1623. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= (a/256)+168;};
  1624. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a%256;};
  1625. /*125:*/
  1626. #line 1586 "tangle.web"
  1627.  
  1628. #line 1587 "tangle.web"
  1629. store_two_bytes(53248);
  1630. if(changing)id_first= change_file_name;
  1631. else id_first= file_name[include_depth];
  1632. id_loc= id_first+strlen(id_first);
  1633. if(changing)store_two_bytes((sixteen_bits)change_line);
  1634. else store_two_bytes((sixteen_bits)line[include_depth]);
  1635. {int a= id_lookup(id_first,id_loc,0)-name_dir;{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= (a/256)+128;};
  1636. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a%256;};}
  1637.  
  1638. /*:125*/
  1639. #line 1553 "tangle.web"
  1640. ;break;
  1641. }
  1642. case 3:case 2:
  1643. /*127:*/
  1644. #line 1605 "tangle.web"
  1645.  
  1646. #line 1606 "tangle.web"
  1647. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a;};
  1648. while(id_first<id_loc){
  1649. if( *id_first==64)id_first++;
  1650. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++=  *id_first++;};
  1651. }
  1652. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a;};break;
  1653.  
  1654. /*:127*/
  1655. #line 1556 "tangle.web"
  1656. ;
  1657. case 249:
  1658. /*128:*/
  1659. #line 1613 "tangle.web"
  1660. {
  1661. #line 1614 "tangle.web"
  1662. int c;
  1663. if( *id_first==64){
  1664. c= xchr[ *id_first++];
  1665. if( *id_first!=64)err_print("! Double @ within string");
  1666. }
  1667. else if( *id_first=='\\'){
  1668. id_first++;
  1669. switch( *id_first){
  1670. case't':c= 9;break;
  1671. case'n':c= 10;break;
  1672. case'b':c= 8;break;
  1673. case'0':c= 0;break;
  1674. case'\\':c= 92;break;
  1675. default:err_print("! Unrecognized escape sequence");
  1676. }
  1677. }
  1678. else c= xchr[ *id_first];
  1679. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 3;};
  1680.  
  1681.  
  1682. app_decimal((long)c);
  1683. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 3;};
  1684. }
  1685. break;
  1686.  
  1687. /*:128*/
  1688. #line 1558 "tangle.web"
  1689. ;
  1690. case 5:
  1691. /*129:*/
  1692. #line 1640 "tangle.web"
  1693. {
  1694. #line 1641 "tangle.web"
  1695. long sum= 0;
  1696. while(id_first<id_loc){
  1697. sum= 8 *sum+ *id_first++-'0';
  1698. if(sum>67108864)err_print("! Octal constant exceeds @\"04000000");
  1699. }
  1700. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 3;};
  1701. app_decimal(sum);
  1702. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 3;};
  1703. }
  1704.  
  1705. /*:129*/
  1706. #line 1560 "tangle.web"
  1707. ;break;
  1708. case 6:
  1709. /*130:*/
  1710. #line 1651 "tangle.web"
  1711. {
  1712. #line 1652 "tangle.web"
  1713. long sum= 0;
  1714. while(id_first<id_loc){
  1715. sum= 16 *sum+
  1716. (isdigit( *id_first)
  1717. ? *id_first-'0'
  1718. :isupper( *id_first)
  1719. ? *id_first-'A'+10
  1720. : *id_first-'a'+10
  1721. );
  1722. id_first++;
  1723. if(sum>67108864)err_print("! Hex constant exceeds @\"04000000");
  1724. }
  1725. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 3;};
  1726. app_decimal(sum);
  1727. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= 3;};
  1728. }
  1729.  
  1730. /*:130*/
  1731. #line 1562 "tangle.web"
  1732. ;break;
  1733. case 10:
  1734. #ifdef NEWLINES_IN_MACROS
  1735. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a;};
  1736. #else
  1737. if(t==1)continue;
  1738. else{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a;};
  1739. #endif NEWLINES_IN_MACROS
  1740. break;
  1741. case 252:case 251:case 253:
  1742. if(t!=254)goto done;
  1743. else{
  1744. err_print("! @d, @f and @u are ignored in C text");continue;
  1745.  
  1746. }
  1747. case 255:goto done;
  1748.  
  1749. /*:124*/
  1750. #line 1334 "tangle.web"
  1751.  
  1752. default:{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= a;};
  1753. }
  1754. }
  1755. done:next_control= (eight_bits)a;
  1756. if(text_ptr>text_info_end){{printf("\n! Sorry, capacity exceeded: ");err_print("text");history= 3;wrap_up();};};
  1757. if(t==1){
  1758. /*110:*/
  1759. #line 1358 "tangle.web"
  1760.  
  1761. #line 1359 "tangle.web"
  1762. tok_ptr-= 2;
  1763. while( *tok_ptr<128&& *(tok_ptr+1)==10)tok_ptr--;
  1764. tok_ptr+= 2;
  1765.  
  1766. /*:110*/
  1767. #line 1341 "tangle.web"
  1768. ;
  1769. }
  1770. cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
  1771. print_where= set_print_where;
  1772. }
  1773.  
  1774. /*:109*//*116:*/
  1775. #line 1408 "tangle.web"
  1776.  
  1777. #line 1409 "tangle.web"
  1778. int parameter_number(first,loc)
  1779. ASCII *first, *loc;
  1780. {
  1781. ASCII *f, *p;
  1782. int n;
  1783. for(n= 0;n<next_param_name;n++){
  1784. if(loc-first==param_names[n+1]-param_names[n]){
  1785.  
  1786. for(f= first,p= param_names[n];f<loc;)
  1787. if( *f++!= *p++)goto nomatch;
  1788. return n+1;
  1789. }
  1790. nomatch:continue;
  1791. }
  1792. return 0;
  1793. }
  1794.  
  1795.  
  1796. /*:116*//*131:*/
  1797. #line 1670 "tangle.web"
  1798.  
  1799. #line 1671 "tangle.web"
  1800. app_decimal(c)
  1801. long c;
  1802. {long power;
  1803. if(c==0){{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= '0';};return;}
  1804. if(c<0){{if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= '-';};c= -c;}
  1805. for(power= 1;c>=power;power *= 10);
  1806.  
  1807. for(power/= 10;power>=1;power/= 10){
  1808. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= '0'+c/power;};
  1809. c%= power;
  1810.  
  1811. }
  1812. }
  1813.  
  1814.  
  1815.  
  1816. /*:131*//*133:*/
  1817. #line 1697 "tangle.web"
  1818. scan_module()
  1819. #line 1698 "tangle.web"
  1820. {
  1821. name_pointer p;
  1822. text_pointer q;
  1823. sixteen_bits a;
  1824. module_count++;
  1825. if( *(loc-1)=='*')
  1826. printf("*%d",module_count);fflush(stdout);
  1827. /*134:*/
  1828. #line 1714 "tangle.web"
  1829.  
  1830. next_control= 0;
  1831. while(1){
  1832. done_scanning:
  1833. while(next_control<=251)
  1834. if((next_control= skip_ahead())==254){
  1835.  
  1836. loc-= 2;next_control= get_next();
  1837. }
  1838. if(next_control!=252)break;
  1839. /*117:*/
  1840. #line 1433 "tangle.web"
  1841.  
  1842. #line 1434 "tangle.web"
  1843. /*123:*/
  1844. #line 1521 "tangle.web"
  1845.  
  1846. #line 1522 "tangle.web"
  1847. while((next_control= get_next())==10);
  1848.  
  1849. /*:123*/
  1850. #line 1434 "tangle.web"
  1851.  
  1852. /*121:*/
  1853. #line 1484 "tangle.web"
  1854.  
  1855. #line 1485 "tangle.web"
  1856. if(next_control!=130){
  1857. err_print("! Macro name must be an identifier");
  1858.  
  1859. /*135:*/
  1860. #line 1732 "tangle.web"
  1861.  
  1862. #line 1733 "tangle.web"
  1863. /*112:*/
  1864. #line 1380 "tangle.web"
  1865.  
  1866. #line 1381 "tangle.web"
  1867. next_param_name= 0;
  1868. next_param_name_text= param_name_texts;
  1869. param_names[next_param_name]= next_param_name_text;
  1870.  
  1871. /*:112*/
  1872. #line 1733 "tangle.web"
  1873. ;
  1874. p->dummy.Ilk= 0;
  1875. goto done_scanning;
  1876.  
  1877.  
  1878. /*:135*/
  1879. #line 1488 "tangle.web"
  1880. ;
  1881. }else{
  1882. p= id_lookup(id_first,id_loc,1);
  1883. if(p->dummy.Ilk!=1){
  1884. #ifdef WARN_USE_BEFORE_DEF
  1885. printf("\n! Warning: macro name ");
  1886. fflush(stdout),write(1,(p)->byte_start,(((p)+1)->byte_start-((p))->byte_start));
  1887. printf(" was used before it was defined");
  1888. {if(history==0)history= 1;};
  1889. #endif WARN_USE_BEFORE_DEF
  1890. p->dummy.Ilk= 1;
  1891. }else if(p+1!=name_ptr){
  1892. err_print("! Macro name is multiply defined: ");
  1893. }
  1894. }
  1895.  
  1896. /*:121*/
  1897. #line 1436 "tangle.web"
  1898. ;
  1899. /*120:*/
  1900. #line 1469 "tangle.web"
  1901.  
  1902. #line 1470 "tangle.web"
  1903. /*123:*/
  1904. #line 1521 "tangle.web"
  1905.  
  1906. #line 1522 "tangle.web"
  1907. while((next_control= get_next())==10);
  1908.  
  1909. /*:123*/
  1910. #line 1470 "tangle.web"
  1911.  
  1912. if(next_control==40){
  1913. do{
  1914. /*122:*/
  1915. #line 1504 "tangle.web"
  1916.  
  1917. #line 1505 "tangle.web"
  1918. /*123:*/
  1919. #line 1521 "tangle.web"
  1920.  
  1921. #line 1522 "tangle.web"
  1922. while((next_control= get_next())==10);
  1923.  
  1924. /*:123*/
  1925. #line 1505 "tangle.web"
  1926. ;
  1927. if(next_control!=130){
  1928. err_print("! Macro parameter name not an identifier");
  1929.  
  1930. /*135:*/
  1931. #line 1732 "tangle.web"
  1932.  
  1933. #line 1733 "tangle.web"
  1934. /*112:*/
  1935. #line 1380 "tangle.web"
  1936.  
  1937. #line 1381 "tangle.web"
  1938. next_param_name= 0;
  1939. next_param_name_text= param_name_texts;
  1940. param_names[next_param_name]= next_param_name_text;
  1941.  
  1942. /*:112*/
  1943. #line 1733 "tangle.web"
  1944. ;
  1945. p->dummy.Ilk= 0;
  1946. goto done_scanning;
  1947.  
  1948.  
  1949. /*:135*/
  1950. #line 1509 "tangle.web"
  1951. ;
  1952. }else{
  1953. if(parameter_number(id_first,id_loc)!=0){
  1954. err_print("! Duplicate parameters in macro definition");
  1955.  
  1956. /*135:*/
  1957. #line 1732 "tangle.web"
  1958.  
  1959. #line 1733 "tangle.web"
  1960. /*112:*/
  1961. #line 1380 "tangle.web"
  1962.  
  1963. #line 1381 "tangle.web"
  1964. next_param_name= 0;
  1965. next_param_name_text= param_name_texts;
  1966. param_names[next_param_name]= next_param_name_text;
  1967.  
  1968. /*:112*/
  1969. #line 1733 "tangle.web"
  1970. ;
  1971. p->dummy.Ilk= 0;
  1972. goto done_scanning;
  1973.  
  1974.  
  1975. /*:135*/
  1976. #line 1514 "tangle.web"
  1977. ;
  1978. }else{
  1979. /*114:*/
  1980. #line 1387 "tangle.web"
  1981.  
  1982. #line 1388 "tangle.web"
  1983. /*115:*/
  1984. #line 1393 "tangle.web"
  1985.  
  1986. #line 1394 "tangle.web"
  1987. if(next_param_name==32)
  1988. {{printf("\n! Sorry, capacity exceeded: ");err_print("parameter names");history= 3;wrap_up();};};
  1989. if(id_loc-id_first>
  1990. param_name_texts_end-next_param_name_text)
  1991. {{printf("\n! Sorry, capacity exceeded: ");err_print("parameter name texts");history= 3;wrap_up();};};
  1992.  
  1993.  
  1994. /*:115*/
  1995. #line 1388 "tangle.web"
  1996. ;
  1997. while(id_first<id_loc)
  1998.  *next_param_name_text++=  *id_first++;
  1999. param_names[++next_param_name]= next_param_name_text;
  2000.  
  2001. /*:114*/
  2002. #line 1516 "tangle.web"
  2003. ;
  2004. }
  2005. }
  2006.  
  2007.  
  2008. /*:122*/
  2009. #line 1473 "tangle.web"
  2010. ;
  2011. /*123:*/
  2012. #line 1521 "tangle.web"
  2013.  
  2014. #line 1522 "tangle.web"
  2015. while((next_control= get_next())==10);
  2016.  
  2017. /*:123*/
  2018. #line 1474 "tangle.web"
  2019.  
  2020. }while(next_control==44);
  2021. if(next_control!=41){
  2022. err_print("! Macro parameter list must end with )");
  2023. /*135:*/
  2024. #line 1732 "tangle.web"
  2025.  
  2026. #line 1733 "tangle.web"
  2027. /*112:*/
  2028. #line 1380 "tangle.web"
  2029.  
  2030. #line 1381 "tangle.web"
  2031. next_param_name= 0;
  2032. next_param_name_text= param_name_texts;
  2033. param_names[next_param_name]= next_param_name_text;
  2034.  
  2035. /*:112*/
  2036. #line 1733 "tangle.web"
  2037. ;
  2038. p->dummy.Ilk= 0;
  2039. goto done_scanning;
  2040.  
  2041.  
  2042. /*:135*/
  2043. #line 1478 "tangle.web"
  2044. ;
  2045. }
  2046. next_control= get_next();
  2047. }
  2048.  
  2049.  
  2050. /*:120*/
  2051. #line 1439 "tangle.web"
  2052. ;
  2053. if(next_control!=61){
  2054. err_print("! You must put an = sign before the macro replacement text");
  2055. /*135:*/
  2056. #line 1732 "tangle.web"
  2057.  
  2058. #line 1733 "tangle.web"
  2059. /*112:*/
  2060. #line 1380 "tangle.web"
  2061.  
  2062. #line 1381 "tangle.web"
  2063. next_param_name= 0;
  2064. next_param_name_text= param_name_texts;
  2065. param_names[next_param_name]= next_param_name_text;
  2066.  
  2067. /*:112*/
  2068. #line 1733 "tangle.web"
  2069. ;
  2070. p->dummy.Ilk= 0;
  2071. goto done_scanning;
  2072.  
  2073.  
  2074. /*:135*/
  2075. #line 1442 "tangle.web"
  2076. ;
  2077. }
  2078. /*118:*/
  2079. #line 1451 "tangle.web"
  2080.  
  2081. #line 1452 "tangle.web"
  2082. #ifdef TRACE_MACROS
  2083. if(tracing>1){
  2084. printf("\nScanning definition of macro ");fflush(stdout),write(1,(p)->byte_start,(((p)+1)->byte_start-((p))->byte_start));
  2085. }
  2086. #endif TRACE_MACROS
  2087.  
  2088. /*:118*/
  2089. #line 1444 "tangle.web"
  2090. ;
  2091. {if(tok_ptr==tok_mem_end){{printf("\n! Sorry, capacity exceeded: ");err_print("token");history= 3;wrap_up();};}; *tok_ptr++= next_param_name;};
  2092. scan_repl(1);
  2093. p->equiv_or_xref= (ASCII *)cur_text;
  2094. /*119:*/
  2095. #line 1458 "tangle.web"
  2096.  
  2097. #line 1459 "tangle.web"
  2098. #ifdef TRACE_MACROS
  2099. if(tracing>2){
  2100. printf("\nMacro ");fflush(stdout),write(1,(p)->byte_start,(((p)+1)->byte_start-((p))->byte_start));
  2101. printf("'s replacement text is in text_info[%d]",cur_text-text_info);
  2102. }
  2103. #endif TRACE_MACROS
  2104.  
  2105.  
  2106. /*:119*/
  2107. #line 1448 "tangle.web"
  2108. ;
  2109. /*112:*/
  2110. #line 1380 "tangle.web"
  2111.  
  2112. #line 1381 "tangle.web"
  2113. next_param_name= 0;
  2114. next_param_name_text= param_name_texts;
  2115. param_names[next_param_name]= next_param_name_text;
  2116.  
  2117. /*:112*/
  2118. #line 1449 "tangle.web"
  2119. ;
  2120.  
  2121. /*:117*/
  2122. #line 1724 "tangle.web"
  2123. ;
  2124. cur_text->text_link= 0;
  2125. }
  2126.  
  2127. /*:134*/
  2128. #line 1705 "tangle.web"
  2129. ;
  2130. /*136:*/
  2131. #line 1738 "tangle.web"
  2132.  
  2133. #line 1739 "tangle.web"
  2134. switch(next_control){
  2135. case 253:p= name_dir;break;
  2136. case 254:p= cur_module;
  2137. /*137:*/
  2138. #line 1750 "tangle.web"
  2139.  
  2140. #line 1751 "tangle.web"
  2141. while((next_control= get_next())=='+');
  2142. if(next_control!='='){
  2143. err_print("! C text flushed, = sign is missing");
  2144.  
  2145. while((next_control= skip_ahead())!=255);
  2146. return;
  2147. }
  2148.  
  2149. /*:137*/
  2150. #line 1742 "tangle.web"
  2151. ;
  2152. break;
  2153. default:return;
  2154. }
  2155. /*138:*/
  2156. #line 1759 "tangle.web"
  2157.  
  2158. #line 1760 "tangle.web"
  2159. store_two_bytes((sixteen_bits)(53248+module_count));
  2160.  
  2161. /*:138*/
  2162. #line 1746 "tangle.web"
  2163. ;
  2164. scan_repl(254);
  2165. /*139:*/
  2166. #line 1762 "tangle.web"
  2167.  
  2168. #line 1763 "tangle.web"
  2169. if(p==name_dir||p==0){
  2170. (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;
  2171. }
  2172. else if(p->equiv_or_xref==(ASCII *)text_info)p->equiv_or_xref= (ASCII *)cur_text;
  2173.  
  2174. else{
  2175. q= (text_pointer)p->equiv_or_xref;
  2176. while(q->text_link<2000)q= q->text_link+text_info;
  2177. q->text_link= cur_text-text_info;
  2178. }
  2179. cur_text->text_link= 2000;
  2180.  
  2181. /*:139*/
  2182. #line 1748 "tangle.web"
  2183. ;
  2184.  
  2185. /*:136*/
  2186. #line 1706 "tangle.web"
  2187. ;
  2188. }
  2189.  
  2190. /*:133*//*140:*/
  2191. #line 1775 "tangle.web"
  2192. phase_one(){
  2193. #line 1776 "tangle.web"
  2194. phase= 1;
  2195. module_count= 0;
  2196. reset_input();
  2197. while((next_control= skip_ahead())!=255);
  2198. while(!input_has_ended)scan_module();
  2199. check_complete();
  2200. phase= 2;
  2201. }
  2202.  
  2203. /*:140*//*141:*/
  2204. #line 1785 "tangle.web"
  2205. print_stats(){
  2206. #line 1786 "tangle.web"
  2207. printf("\nMemory usage statistics:\n");
  2208. printf("%d names (out of %d)\n",name_ptr-name_dir,4000);
  2209. printf("%d replacement texts (out of %d)\n",text_ptr-text_info,2000);
  2210. printf("%d bytes (out of %d)\n",byte_ptr-byte_mem,90000);
  2211. printf("%d tokens (out of %d)\n",tok_ptr-tok_mem,150000);
  2212. }
  2213.  
  2214. /*:141*/
  2215.